package com.zbkj.service.service.invoice.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.zbkj.common.invoice.PeInvoiceApply;
import com.zbkj.common.model.order.OrderInfo;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.service.dao.invoice.PeInvoiceApplyMapper;
import com.zbkj.service.service.invoice.IPeInvoiceApplyService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 用户发票申请记录 服务实现类
 * </p>
 *
 * @author 
 * @since 2025-08-05
 */
@Service
public class PeInvoiceApplyServiceImpl extends ServiceImpl<PeInvoiceApplyMapper, PeInvoiceApply> implements IPeInvoiceApplyService {

    @Override
    public PageInfo<PeInvoiceApply> getUserInvoice(PageParamRequest pageParamRequest, Long userId) {
        List<PeInvoiceApply> list = Lists.newArrayList();
        if(Objects.isNull(userId)) {
            return new PageInfo<>(list);
        }
        LambdaQueryWrapper<PeInvoiceApply> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PeInvoiceApply::getDeleteFlag,0)
                .eq(PeInvoiceApply::getUserId,userId)
                .orderByDesc(PeInvoiceApply::getCreateTime);
        Page<PeInvoiceApply> pageObj = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
        list = this.list(wrapper);
        return CommonPage.copyPageInfo(pageObj, list);
    }
}
